//
//  InvestOtherCell.m
//  TenThousand
//
//  Created by 我的 on 16/6/6.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "InvestOtherCell.h"

@implementation InvestOtherCell
{
    NSString *show;
    UILabel *labe;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    CGFloat width = 70;
    _pieChartView = [[PieProgressBar alloc]initWithFrame:CGRectMake(Screen_Width -100, 20, width, width)];
    
    [self.contentView addSubview:_pieChartView];
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}


- (void)drawRect:(CGRect)rect{
     _progressView.layer.cornerRadius = 3;
    _progressView.layer.masksToBounds = YES;
    
}

//cell赋值
- (void)setDataWithModel:(BorrowListModel *)model{
    
    _titleLabel.text = [NSString stringWithFormat:@"%@%@",model.ProjectName,model.Code];//借款编号
    _termLabel.text = model.Term;//期限
    _minAmountLabel.text = [NSString stringWithFormat:@"%.2f元起投",model.MinAmount];//最低起投
    _tenderLabel.text = [NSString stringWithFormat:@"%.2f%%",[model.proportion floatValue]];//投标人数
//    [_progressView setProgress:[model.proportion floatValue]/100 animated:NO];
    _fasate.text = [NSString stringWithFormat:@"%@",model.FaSate];
    [_pieChartView updatePercent:[model.proportion floatValue] animation:YES];
    
    
    _rateLabel.text = [NSString stringWithFormat:@"%.2f%%",model.Rate];//年利率
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:self.rateLabel.text];
    //设置字号
    [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:25.0f] range:NSMakeRange(self.rateLabel.text.length-3, 3)];
    self.rateLabel.attributedText = str;
    
    NSArray *arr = [model.MaxPrice componentsSeparatedByString:@"."];
    if ([arr[0] length] >= 5) {
        NSString *a =     [arr[0] substringToIndex: [arr[0] length] - 4];
        NSRange range1 = NSMakeRange([arr[0] length] - 4, 1);
        show = [NSString stringWithFormat:@"%@.%@万元",a,[arr[0] substringWithRange:range1]];
    }
    if ([arr[0] length] < 5) {
        if (arr.count > 1) {
            show = [NSString stringWithFormat:@"%@.%@元",arr[0],[arr[1] substringToIndex:1]];
        }else{
            show = [NSString stringWithFormat:@"%@元",arr[0]];
        }
        
        
    }
    
    _max.text = [NSString stringWithFormat:@"项目总额:%@",show];

}

@end
